// scaup - Scala up!
// (c) 2009, Normen Müller, normen.mueller@gmail.com  
// $Id: Parser.scala 40 2009-11-10 18:59:19Z normen.mueller $
package scaup.draft.eq

import java.io.File

import scala.util.parsing.combinator._
import scala.util.parsing.combinator.syntactical._

import scaup.Views._

private [eq] case class Element(val name: String, val scope: String, val annotations: Set[String], val constituents: Set[String])

/** An equivalence system parser.
 *
 * @author <a href="mailto:normen.mueller@googlemail.com">Normen M&#xFC;ller</a>
 * @version 0.0.2 */
private [eq] class Parser extends StdTokenParsers with ImplicitConversions {  
  /* Fill in abstract defs*/
  type Tokens = Lexer
  val lexical: Tokens = new Lexer
  
  /* Configure lexical parsing */                                 
  lexical.reserved ++= List( )
  
  lexical.delimiters ++= List( ) 
  
  /* Define the grammar */
  def eq[T](system: EquivalenceSystem[T]) = string ^^ {
    case string =>
//      val elems : Set[Element] = Set()      
//      val tmp = (system /: elems)(_ + _)      

      
//      (map /: elems)((m, e) => e match {
//        case Element(name, scope, annos, cons) =>
//          if (! (annos isEmpty))
//            m + {(
//              ((scope, name)),
//              new Equiv[String] { def equiv(x: String, y: String) = x == y }
//            )}
//          else m          
//      })
      
      string
  }
  
  lazy val string = accept("string",  {case lexical.StringLit(n) => n mkString ("\"", "", "\"") })

}